package com.tanhua.dubbo.api.impl;

import com.tanhua.domain.mongo.Examination;
import com.tanhua.domain.vo.ExaminationVo;
import com.tanhua.dubbo.api.ExaminationApi;
import org.apache.dubbo.config.annotation.Service;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

@Service
public class ExaminationApiImpl implements ExaminationApi {

    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public void saveExamination(Examination examination) {
        mongoTemplate.save(examination);
    }

    @Override
    public List<Examination> findAllExamination() {
        Query query = new Query();
        List<Examination> examinationList = mongoTemplate.find(query, Examination.class);
        return examinationList;
    }

    @Override
    public Examination findExaminationById(ObjectId objectId) {

        return mongoTemplate.findById(objectId, Examination.class);
    }
}
